import { TreeSelect, TreeSelectProps } from "antd";
import { BaseOptionType } from "antd/lib/select";
import { FC, useEffect, useState } from "react";
import { getAreaTreeData } from "src/util/data";

const AreaSelect: FC<TreeSelectProps> = props => {
	const [areaTreeData, setAreaTreeData] = useState<BaseOptionType[]>([]);
	useEffect(() => {
		const treeData = getAreaTreeData();
		setAreaTreeData(treeData);
	}, []);
	return <TreeSelect showSearch allowClear treeExpandAction="click" placeholder="请选择或搜索城市" treeData={areaTreeData} {...props} />;
};

export default AreaSelect;
